/**
 * Created by 小敏哥 on 2017/11/28.
 */
import React, {Component} from 'react';
import {connect} from 'react-redux';
import style from './index.scss'
import Process from '../../../../../../src/js/components/process';
import common from '../../../../../js/utils/common'
class ProcessDetail extends Component {
    constructor(props) {
        super(props);
        this.testAndRedirect();
    }


    //无数据时返回上一级防止报错
    testAndRedirect() {
        if(!this.props.processlist){
            history.back();
        }
    }


    componentDidMount(){
        common.setViewTitle('进度详情');
    }

    structData(){
        if(this.props.processlist) {
            return this.props.processlist.map((item, index) => {
                return {
                    name: item.name,
                    updateTime: common.transfromDateTime(new Date(item.updateTime))
                }
            })
        }
        return [];
    }

    render(){
        let data=this.structData();
        return this.props.processlist?<div className={style.processDetail}>
            <div className={style.header}>
                <div><span>{this.props.cardName} </span><span>身份证邮寄业务办理</span></div>
                <div><span>订单号 </span><span>{this.props.orderId}</span></div>
            </div>

           {/* <div className={style.serviceMessage}>
                <img src="./images/EMSlogo.png"/>
                <div className={style.content}>
                    <div>居民身份证邮寄服务</div>
                    <div>客服电话：11183</div>
                </div>
            </div>*/}
            <div className={style.content}>
                <Process status={this.props.processlist.length-1} processArray={this.structData()}></Process>
            </div>
        </div>:<div></div>;
    }
}

function mapStateToProps(state) {
    return Object.assign({}, state.orderDetailInfo.orderDetailInit);
}


export default connect(mapStateToProps)(ProcessDetail);